package com.example.webviewdemo1;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.webkit.WebView;
import android.widget.LinearLayout;

public class WebViewDetail extends LinearLayout {

	private View mView;
	Context mycontext;
	public WebView mWebView;

	public WebViewDetail(Context context) {
		super(context);
		mycontext = context;
		LayoutInflater inflater;
		inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		mView = inflater.inflate(R.layout.webview_detail, this);
		mWebView = (WebView) mView.findViewById(R.id.webView);
	}

	@Override
	protected void onLayout(boolean changed, int l, int t, int r, int b) {
		// TODO Auto-generated method stub
		super.onLayout(changed, l, t, r, b);

	}

	public void loadData() {
		String mCustomHtml = "<h1>Test 0</h1></br>";
		for (int i = 1; i < 100; i++) {
			mCustomHtml += "<h1>Test " + String.valueOf(i) + "</h1></br>";
		}
		mWebView.loadData(mCustomHtml, "text/html; charset=UTF-8", null);
	}

	public void scrollTo(int y) {
		mWebView.scrollTo(0, y);
	}
}
